<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Docker 安装 GitLab Runner | lin</title>
    <meta name="generator" content="VuePress 1.5.4">
    <link rel="icon" href="/favicon.ico">
    <script src="/randomRibbon.js"></script>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    <link rel="preload" href="/assets/css/0.styles.7b6e6166.css" as="style"><link rel="preload" href="/assets/js/app.9eeb3618.js" as="script"><link rel="preload" href="/assets/js/4.615f843c.js" as="script"><link rel="preload" href="/assets/js/1.8bd0e602.js" as="script"><link rel="preload" href="/assets/js/33.228fb796.js" as="script"><link rel="prefetch" href="/assets/js/10.3559d115.js"><link rel="prefetch" href="/assets/js/11.12c5aba2.js"><link rel="prefetch" href="/assets/js/12.a3fd9b76.js"><link rel="prefetch" href="/assets/js/13.e6809a95.js"><link rel="prefetch" href="/assets/js/14.adef333c.js"><link rel="prefetch" href="/assets/js/15.8bb427ec.js"><link rel="prefetch" href="/assets/js/16.1bfa9cb0.js"><link rel="prefetch" href="/assets/js/17.5a3737e4.js"><link rel="prefetch" href="/assets/js/18.d8dad8dd.js"><link rel="prefetch" href="/assets/js/19.8f899ab3.js"><link rel="prefetch" href="/assets/js/2.cc2f2b76.js"><link rel="prefetch" href="/assets/js/20.9fa36d07.js"><link rel="prefetch" href="/assets/js/21.079012f5.js"><link rel="prefetch" href="/assets/js/22.8cfb9ca9.js"><link rel="prefetch" href="/assets/js/23.d3b22b6b.js"><link rel="prefetch" href="/assets/js/24.16735cab.js"><link rel="prefetch" href="/assets/js/25.861db340.js"><link rel="prefetch" href="/assets/js/26.7a6ddca7.js"><link rel="prefetch" href="/assets/js/27.35cb20a8.js"><link rel="prefetch" href="/assets/js/28.664c4fa6.js"><link rel="prefetch" href="/assets/js/29.c5cad407.js"><link rel="prefetch" href="/assets/js/30.45c8a563.js"><link rel="prefetch" href="/assets/js/31.dbbe4a19.js"><link rel="prefetch" href="/assets/js/32.374d9c33.js"><link rel="prefetch" href="/assets/js/34.cc1b3087.js"><link rel="prefetch" href="/assets/js/35.105d7e30.js"><link rel="prefetch" href="/assets/js/36.cf8b731d.js"><link rel="prefetch" href="/assets/js/37.6ec4374a.js"><link rel="prefetch" href="/assets/js/38.4865445a.js"><link rel="prefetch" href="/assets/js/39.fea71b3f.js"><link rel="prefetch" href="/assets/js/40.6481b1b0.js"><link rel="prefetch" href="/assets/js/41.6593fbec.js"><link rel="prefetch" href="/assets/js/42.5dbcc3da.js"><link rel="prefetch" href="/assets/js/43.ac388084.js"><link rel="prefetch" href="/assets/js/44.fdc07e4c.js"><link rel="prefetch" href="/assets/js/45.a475b975.js"><link rel="prefetch" href="/assets/js/46.2f29191f.js"><link rel="prefetch" href="/assets/js/47.2531c283.js"><link rel="prefetch" href="/assets/js/48.c5dc9465.js"><link rel="prefetch" href="/assets/js/49.c05cb5a7.js"><link rel="prefetch" href="/assets/js/5.d4c7ff9d.js"><link rel="prefetch" href="/assets/js/50.2db82c26.js"><link rel="prefetch" href="/assets/js/6.de2974b2.js"><link rel="prefetch" href="/assets/js/7.2cc3e685.js"><link rel="prefetch" href="/assets/js/8.443e24e1.js"><link rel="prefetch" href="/assets/js/9.2b149c01.js">
    <link rel="stylesheet" href="/assets/css/0.styles.7b6e6166.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container" data-v-0a66d9e0><div data-v-0a66d9e0><div id="loader-wrapper" class="loading-wrapper" data-v-d48f4d20 data-v-0a66d9e0 data-v-0a66d9e0><div class="loader-main" data-v-d48f4d20><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-5cb9a64e data-v-0a66d9e0 data-v-0a66d9e0><h3 class="title" style="display:none;" data-v-5cb9a64e data-v-5cb9a64e>lin</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-5cb9a64e data-v-5cb9a64e><input type="password" value="" data-v-5cb9a64e> <span data-v-5cb9a64e>Konck! Knock!</span> <button data-v-5cb9a64e>OK</button></label> <div class="footer" style="display:none;" data-v-5cb9a64e data-v-5cb9a64e><span data-v-5cb9a64e><i class="iconfont reco-theme" data-v-5cb9a64e></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-5cb9a64e>vuePress-theme-reco</a></span> <span data-v-5cb9a64e><i class="iconfont reco-copyright" data-v-5cb9a64e></i> <a data-v-5cb9a64e><span data-v-5cb9a64e>lin</span>
            
          <span data-v-5cb9a64e>2020 - </span>
          2021
        </a></span></div></div> <div class="hide" data-v-0a66d9e0><header class="navbar" data-v-0a66d9e0><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/logo.png" alt="lin" class="logo"> <span class="site-name">lin</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>
  首页
</a></div><div class="nav-item"><a href="/docs/notebook/docker/docker1.html" class="nav-link"><i class="iconfont reco-other"></i>
  笔记
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/动态/" class="nav-link"><i class="iconfont undefined"></i>
  动态
</a></li><li class="dropdown-item"><!----> <a href="/categories/部署/" class="nav-link"><i class="iconfont undefined"></i>
  部署
</a></li><li class="dropdown-item"><!----> <a href="/categories/Java/" class="nav-link"><i class="iconfont undefined"></i>
  Java
</a></li><li class="dropdown-item"><!----> <a href="/categories/推荐/" class="nav-link"><i class="iconfont undefined"></i>
  推荐
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/message/" class="nav-link"><i class="iconfont reco-suggestion"></i>
  留言板
</a></div><div class="nav-item"><a href="/about/" class="nav-link"><i class="iconfont reco-account"></i>
  关于我
</a></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-0a66d9e0></div> <aside class="sidebar" data-v-0a66d9e0><div class="personal-info-wrapper" data-v-03833281 data-v-0a66d9e0><img src="/avatar.png" alt="author-avatar" class="personal-img" data-v-03833281> <h3 class="name" data-v-03833281>
    lin
  </h3> <div class="num" data-v-03833281><div data-v-03833281><h3 data-v-03833281>38</h3> <h6 data-v-03833281>文章</h6></div> <div data-v-03833281><h3 data-v-03833281>13</h3> <h6 data-v-03833281>标签</h6></div></div> <hr data-v-03833281></div> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>
  首页
</a></div><div class="nav-item"><a href="/docs/notebook/docker/docker1.html" class="nav-link"><i class="iconfont reco-other"></i>
  笔记
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/动态/" class="nav-link"><i class="iconfont undefined"></i>
  动态
</a></li><li class="dropdown-item"><!----> <a href="/categories/部署/" class="nav-link"><i class="iconfont undefined"></i>
  部署
</a></li><li class="dropdown-item"><!----> <a href="/categories/Java/" class="nav-link"><i class="iconfont undefined"></i>
  Java
</a></li><li class="dropdown-item"><!----> <a href="/categories/推荐/" class="nav-link"><i class="iconfont undefined"></i>
  推荐
</a></li></ul></div></div><div class="nav-item"><a href="/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/message/" class="nav-link"><i class="iconfont reco-suggestion"></i>
  留言板
</a></div><div class="nav-item"><a href="/about/" class="nav-link"><i class="iconfont reco-account"></i>
  关于我
</a></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>自动化部署</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading open"><span>Docker</span> <span class="arrow down"></span></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/notebook/docker/docker1.html" class="sidebar-link">什么是Docker</a></li><li><a href="/docs/notebook/docker/docker2.html" class="sidebar-link">为什么要使用 Docker</a></li><li><a href="/docs/notebook/docker/docker3.html" class="sidebar-link">Docker 基本概念</a></li><li><a href="/docs/notebook/docker/docker4.html" class="sidebar-link">Docker 的安装及基本语法</a></li><li><a href="/docs/notebook/docker/docker5.html" class="sidebar-link">Docker 实践</a></li></ul></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>Dockerfile</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>Docker Compose</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>私有 Docker 仓库</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>持续集成</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>离线安装</span> <span class="arrow right"></span></p> <!----></section></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>Nexus3</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/notebook/nexus/docker-nexus3.html" class="sidebar-link">Docker 安装 Nexus3 及使用</a></li><li><a href="/docs/notebook/nexus/docker-nexus-maven.html" class="sidebar-link">Maven 私服配置</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Git</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/notebook/git/docker-gitlab.html" class="sidebar-link">Docker 安装 GitLab</a></li><li><a href="/docs/notebook/git/git.html" class="sidebar-link">Git 命令操作</a></li><li><a href="/docs/notebook/git/git-ssh.html" class="sidebar-link">Git 使用 ssh 免密登录</a></li><li><a href="/docs/notebook/git/docker-runner.html" aria-current="page" class="active sidebar-link">Docker 安装 GitLab Runner</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>Docker Images</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/notebook/images/docker-registry.html" class="sidebar-link">Docker 安装 Registry</a></li><li><a href="/docs/notebook/images/docker-registry-project.html" class="sidebar-link">Docker 打包 Java 项目</a></li><li><a href="/docs/notebook/images/docker-harbor.html" class="sidebar-link">搭建 Harbor 私服</a></li><li><a href="/docs/notebook/images/docker-project.html" class="sidebar-link">Docker 运行镜像项目</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>Oracle</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/notebook/oracle/docker-oracle.html" class="sidebar-link">Docker 安装 Oracle 11g</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>Mysql</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/notebook/mysql/docker-mysql.html" class="sidebar-link">Docker 安装 MySQL</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>Redis</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/notebook/redis/docker-redis.html" class="sidebar-link">Docker 安装 Redis Sentinel 集群</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>Zookeeper</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/notebook/zookeeper/docker-zookeeper.html" class="sidebar-link">Docker 安装 Zookeeper 集群</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>Nginx</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/notebook/nginx/docker-nginx.html" class="sidebar-link">Docker 安装 Nginx 和使用</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>自动化部署</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/notebook/auto/docker-jenkins.html" class="sidebar-link">Docker 安装和部署 Jenkins</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>Nacos</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/notebook/nacos/docker-nacos.html" class="sidebar-link">Docker 安装和部署 Nacos</a></li></ul></section></li></ul> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-5cb9a64e data-v-0a66d9e0><h3 class="title" style="display:none;" data-v-5cb9a64e data-v-5cb9a64e>Docker 安装 GitLab Runner</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-5cb9a64e data-v-5cb9a64e><input type="password" value="" data-v-5cb9a64e> <span data-v-5cb9a64e>Konck! Knock!</span> <button data-v-5cb9a64e>OK</button></label> <div class="footer" style="display:none;" data-v-5cb9a64e data-v-5cb9a64e><span data-v-5cb9a64e><i class="iconfont reco-theme" data-v-5cb9a64e></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-5cb9a64e>vuePress-theme-reco</a></span> <span data-v-5cb9a64e><i class="iconfont reco-copyright" data-v-5cb9a64e></i> <a data-v-5cb9a64e><span data-v-5cb9a64e>lin</span>
            
          <span data-v-5cb9a64e>2020 - </span>
          2021
        </a></span></div></div> <div data-v-0a66d9e0><main class="page" style="padding-right:0;"><div class="hero" style="text-align:center;overflow:hidden;background:url(/img/6.jpg) center/cover no-repeat;"><!----> <div class="page-title" style="display:none;"><h1 class="title">Docker 安装 GitLab Runner</h1> <div class="pageinfo" data-v-859c3354><i class="iconfont reco-account" data-v-859c3354><span data-v-859c3354>lin</span></i> <i class="iconfont reco-date" data-v-859c3354><span data-v-859c3354>2020-11-13</span></i> <i class="iconfont reco-eye" data-v-859c3354><span id="/docs/notebook/git/docker-runner.html" data-flag-title="Your Article Title" class="leancloud-visitors" data-v-859c3354><a class="leancloud-visitors-count" style="font-size:.9rem;font-weight:normal;color:#f5eeee;"></a></span></i> <i class="iconfont reco-tag tags" data-v-859c3354><span class="tag-item" data-v-859c3354>docker</span><span class="tag-item" data-v-859c3354>git</span><span class="tag-item" data-v-859c3354>runner</span></i></div></div></div> <div class="theme-reco-content content__default" style="display:none;"><p>文件准备</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>apache-maven-3.6.1-bin.tar.gz
jdk-8u152-linux-x64.tar.gz
docker-compose-linux-x86_64.tar.gz
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>环境准备<br></p> <ul><li>创建工作目录</li></ul> <div class="language- line-numbers-mode"><pre class="language-text"><code> /usr/local/docker/runner
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>创建构建目录</li></ul> <div class="language- line-numbers-mode"><pre class="language-text"><code> /usr/local/docker/runner/environment    
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>下载 jdk-8u152-linux-x64.tar.gz 并复制到</li></ul> <div class="language- line-numbers-mode"><pre class="language-text"><code>/usr/local/docker/runner/environment 
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>下载 apache-maven-3.5.3-bin.tar.gz 并复制到</li></ul> <div class="language- line-numbers-mode"><pre class="language-text"><code>/usr/local/docker/runner/environment
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>目录下创建 daemon.json，用于配置加速器和仓库地址 (<code>/usr/local/docker/runner/environment</code> )</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>{
  &quot;registry-mirrors&quot;: [
    &quot;https://registry.docker-cn.com&quot;
  ],
  &quot;insecure-registries&quot;: [
    &quot;192.168.10.133:5000&quot;
  ]
}
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>在 Dockerfile</p> <div class="language- line-numbers-mode"><pre class="language-text"><code> /usr/local/docker/runner/environment 
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>目录下创建 Dockerfile</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>FROM gitlab/gitlab-runner:v11.0.2
MAINTAINER linlong &lt;topsale@vip.qq.com&gt;

# 修改软件源
RUN echo 'deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse' &gt; /etc/apt/sources.list &amp;&amp; \
    echo 'deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse' &gt;&gt; /etc/apt/sources.list &amp;&amp; \
    echo 'deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse' &gt;&gt; /etc/apt/sources.list &amp;&amp; \
    echo 'deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse' &gt;&gt; /etc/apt/sources.list &amp;&amp; \
    apt-get update -y &amp;&amp; \
    apt-get clean

# 安装 Docker
RUN apt-get -y install apt-transport-https ca-certificates curl software-properties-common &amp;&amp; \
    curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | apt-key add - &amp;&amp; \
    add-apt-repository &quot;deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable&quot; &amp;&amp; \
    apt-get update -y &amp;&amp; \
    apt-get install -y docker-ce
COPY daemon.json /etc/docker/daemon.json

# 安装 Docker Compose
WORKDIR /usr/local/bin
#RUN wget https://raw.githubusercontent.com/topsale/resources/master/docker/docker-compose
COPY docker-compose-Linux-x86_64 /usr/bin/docker-compose
RUN chmod +x /usr/bin/docker-compose

# 安装 Java
RUN mkdir -p /usr/local/java
WORKDIR /usr/local/java
COPY jdk-8u152-linux-x64.tar.gz /usr/local/java
RUN tar -zxvf jdk-8u152-linux-x64.tar.gz &amp;&amp; \
    rm -fr jdk-8u152-linux-x64.tar.gz

# 安装 Maven
RUN mkdir -p /usr/local/maven
WORKDIR /usr/local/maven
# RUN wget https://raw.githubusercontent.com/topsale/resources/master/maven/apache-maven-3.6.1-bin.tar.gz
COPY apache-maven-3.6.1-bin.tar.gz /usr/local/maven
RUN tar -zxvf apache-maven-3.6.1-bin.tar.gz &amp;&amp; \
    rm -fr apache-maven-3.6.1-bin.tar.gz
# COPY settings.xml /usr/local/maven/apache-maven-3.6.1/conf/settings.xml

# 配置环境变量
ENV JAVA_HOME /usr/local/java/jdk1.8.0_152
ENV MAVEN_HOME /usr/local/maven/apache-maven-3.6.1
ENV PATH $PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin

WORKDIR / 
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br></div></div><p>在 /usr/local/docker/runner 目录下创建 docker-compose.yml</p> <div class="language- line-numbers-mode"><pre class="language-text"><code> version: '3.1'
 services:
   gitlab-runner:
     build: environment
     restart: always
     container_name: gitlab-runner
     privileged: true
     volumes:
       - ./config:/etc/gitlab-runner
       - /var/run/docker.sock:/var/run/docker.sock
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>注册 Runner</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>docker exec -it gitlab-runner gitlab-runner register

# 输入 GitLab 地址
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://192.168.10.132/

# 输入 GitLab Token
Please enter the gitlab-ci token for this runner:
1Lxq_f1NRfCfeNbE5WRh

# 输入 Runner 的说明
Please enter the gitlab-ci description for this runner:
可以为空

# 设置 Tag，可以用于指定在构建规定的 tag 时触发 ci
Please enter the gitlab-ci tags for this runner (comma separated):
deploy

# 这里选择 true ，可以用于代码上传后直接执行
Whether to run untagged builds [true/false]:
true

# 这里选择 false，可以直接回车，默认为 false
Whether to lock Runner to current project [true/false]:
false

# 选择 runner 执行器，这里我们选择的是 shell
Please enter the executor: virtualbox, docker+machine, parallels, shell, ssh, docker-ssh+machine, kubernetes, docker, docker-ssh:
shell
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br></div></div><p>四个阶段</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>1. build
构建项目
2. push 
上传代码
3. run
启动镜像项目
4. clean
清理虚悬镜像
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>制作Dockerfile检查前置条件的工具</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>dockerize-linux-amd64-v0.6.1.tar
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></div> <footer class="page-edit" style="display:none;"><!----> <div class="last-updated"><span class="prefix">Last Updated: </span> <span class="time">2021/1/13 上午11:52:37</span></div></footer> <!----> <!----> <!----></main> <!----></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-c6073ba8 data-v-c6073ba8><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-c6073ba8><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-c6073ba8></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-c6073ba8></path></svg></div><div></div><canvas id="vuepress-canvas-cursor"></canvas></div></div>
    <script src="/assets/js/app.9eeb3618.js" defer></script><script src="/assets/js/4.615f843c.js" defer></script><script src="/assets/js/1.8bd0e602.js" defer></script><script src="/assets/js/33.228fb796.js" defer></script>
  </body>
</html>
